﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogicUniversityBiz;

namespace LogicUniversity.clerks
{
    public partial class MaintainSupplierList1 : System.Web.UI.Page
    {
        protected void Page_PreInit(Object sender, EventArgs e)
        {
            //(Session["Role"]
            if (Session["Role"] as string != "Clerk")
            {
                Response.Redirect("~/Login.aspx");
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //DataBind();
                fillDataGrid();
            }
        }

        public void fillDataGrid()
        {
            MaintainSupplier mtSupplier = new MaintainSupplier();

            List<Supplier> supplierList = mtSupplier.getSupplierList();

            GridView1.DataSource = supplierList;
            GridView1.DataBind();
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("AddSupplier.aspx");
        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow row = GridView1.SelectedRow;

            string supplierCode = row.Cells[1].Text.ToString();//获得第一个单元格的值
            string supplierName = row.Cells[2].Text.ToString();
            string contactName = row.Cells[3].Text.ToString();
            string phoneNo = row.Cells[4].Text.ToString();
            string faxNo = row.Cells[5].Text.ToString();
            string address = row.Cells[6].Text.ToString();

            Session["SupplierCode"] = supplierCode;
            Session["SupplierName"] = supplierName;
            Session["ContactName"] = contactName;
            Session["PhoneNo"] = phoneNo;
            Session["FaxNo"] = faxNo;
            Session["Address"] = address;

            Response.Redirect("ModifySupplier.aspx");
        }

        //public override void VerifyRenderingInServerForm(Control control)
        //{ 
        //}
    }
}